/**
 * @copyright Copyright (c) 2023..
 *
 * @file    common_opr_http.h
 * @brief   描述 通用HTTP接口头
 * @author  HC(202206728@any3.com)
 * @version 1.0
 * @date    2023-09-27
 */
#ifndef COMMON_OPR_HTTP_H
#define COMMON_OPR_HTTP_H

#include <string>
#include <map>
#include <vector>
#include <fstream>

using namespace std;

class CommonOprHttp
{
public:
    CommonOprHttp();
    ~CommonOprHttp();

    bool getDomainHostPort(string udsDomainUrl, string domainName, string &hostName, int &PortName);
    // 获取子系统域名
    bool getSubSysDomain(string childUrl, string domainName);

    bool doHttpGetRequest(const string &url, map<string,string> &http_headermap, bool withAuthorization, string &o_resposeBuff);
    bool httpReqInit(string domainName);


    bool doHttpPostRequest(const string &url, map<string, string> &http_headermap, string &postfiled, bool withAuthorization, string &o_resposeBuff);
    string GenAuthorization(string reqType, const string &url, map<string,string> http_headermap, const string &postfiled);

    bool doHttpUploadFile(std::string &o_resposeBuff, const std::string &url_addr, const std::string &fcToken, const std::string &headerMsg, const std::string &fileName, const std::string &headerValue, bool isChunk);
    bool getCloudConfig(string addr, map<string, string> &http_headermap, string &o_resposeBuff);

    // 下载标定文件
    bool getCalibrationFile(const string &addr, map<string, string> &http_headermap, string &o_resposeBuff, string &uploadParam, bool withAuthorization, bool isUploadFile);

	string domainHost;
	int    domainPort;
    std::string hu_tokenMsg;
    std::string hu_secretKey;

    // string s_udsDomainUrl;
    // map<string, string> m_subSysDomain;
private:
	bool loginGethutocken();
    bool updateHuTocken();

};

#endif